All Questions
24 questions
-1votes
2answers
592views
Output date into specific column using bash
I want to output the date into a csv column using a bash script ignoring the header. I have this but it only gives the day of the week abbreviated and not does not place it in a specific column: date |...
1vote
4answers
917views
Given a weekday name, week of a month, and a year, how to find the date
I can find the last Monday using date -d 'last-monday' +%F but given a weekday name, week of a month, and a year, how to find the date? e.g. given: Monday, Week 4, June, 2022 output: 2022-06-20 given: ...
0votes
0answers
13views
Issue in calculating elapsed time in millisecond date command not found [duplicate]
I have the following code trying to calculate how much time it takes in milliseconds to build a docker container. However I am facing syntax error and command not found issue, running bash script bash ...
0votes
1answer
268views
Comparing dates of different formats and matching it from another file
I have two data files with date stamps in different formats (as text in the file contents). I wish to compare the two dates and print the variable from one file to another according to date in a ...
0votes
1answer
234views
Display time logged in by hour(s) and minute(s)
I am writing a script to display how long a user has been logged in. who | grep "$userid" | awk '{print $1,$3,$4}' | while read user time; do \echo $(($(($(date +%s) - $(date -d "$time" +%s)))/60)) ...
0votes
2answers
460views
Bash Time Difference
I have a log file and I need to make some calculations between two jobs to find time difference. In my log file I am supposed to calculate time between the jobs incoming request and candidate list ...
-2votes
1answer
1kviews
Insert today's date at the end of a text file - using bash
I have a text files that is generated through daily running bash script - I want to append a date field into that text file - how can I achieve it ? Name NUM_OF_USERS A------10 B------20 **date-...
1vote
1answer
206views
writing a script that finds incorrect files, and corrects them through stdout
I am currently using UNIX bash, and I want to write shell script that allows me to correct the date entry by using information in a file's pathname. Background: I previously had 200 files that were ...
-1votes
1answer
1kviews
calendar different between 2 dates [duplicate]
Convert your days alive to use dialog command and a calendar for date of birth select and current date Hint: dialog --stdout --title "Today" --calendar "today" 0 0 0 0 0 | awk -F/ '{ print $2"/"$1"/...
1vote
3answers
4kviews
Rename files but retain files original time stamp in name
I have a list of a few hundred files. They are currently as below: filename.New_20160901.dat filename.New_20160902.dat ... etc., all the way up to filename.New_<current date>.dat I have a ...
-1votes
2answers
6kviews
Adding timestamp to TOP command output [closed]
I need to monitor CPU and memory utilization/user by date/timestamp(hourly). In below 'TOP' command I need to add date/timestamp field also, so that I can prepare hourly rpeort of CPU usage Can ...
1vote
1answer
135views
Bash format returns zeroes for H M [closed]
I'm trying to understand this behaviour of date in bash script. When I call date by itself and when I format the date I get different outputs. date Wed Aug 31 22:12:25 EDT 2016 date --date="$NOW" +"%...
4votes
2answers
8kviews
Millisecond time in a shell script
How can someone print the entire time ie, for example 12:07:59:393(HH:MM:SS:milliseconds) in milliseconds. I found a lot of posts saying how to print Milliseconds along witht HHMMSS but I want to ...
6votes
3answers
3kviews
How to sleep until a given date & time?
I want to write a shell where given a date (day-hour-min) e.g. 10:00 AM Sun 2:30 PM Mon ... It sleeps until that exact date & time. I thought one way of doing it is, I could get the current date ...
3votes
2answers
12kviews
Subtract two dates using Shell Scripting [duplicate]
How can I subtract two dates in epoch format using Shell Scripting. I want the output in Months, Days, Hours format. Also It should work even for more than 12 months ( as I came across few which were ...